﻿using MapleLeaf.Pay.Trade;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MapleLeaf.Pay.Pay {

    public class HongshPayClientContext : INotifyPropertyChanged {


        public event PropertyChangedEventHandler PropertyChanged;


        public int CashAmount { get; private set; }

        public string CashAmountString {
            get => (CashAmount / 100.0).ToString("0.00");
            set {
                try {
                    CashAmount = (int)(double.Parse(value) * 100.0);
                }
                catch {
                    CashAmount = 0;
                }
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("CashAmountString"));
            }
        }


        public string CashAuthcode {
            get => _CashAuthcode;
            set {
                _CashAuthcode = value;
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("CashAuthcode"));
            }
        }

        public TradeState CashState {
            get => _CashState;
            set {
                _CashState = value;
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("CashState"));
            }
        }

        public string CashStateDescript {
            get => _CashStateDescript;
            set {
                _CashStateDescript = value;
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("CashStateDescript"));
            }
        }

        public int CashTime {
            get => _CashTime;
            set {
                _CashTime = value;
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("CashTime"));
            }
        }

        public List<HongshPayClientPlugin> Plugins { get; }

        public HongshPayClientConfig Config { get; }


        public HongshPayTradeManager TradeManager { get; }


        private HongshPayClientContext() {
            //Class18.LVfVa0hzXO4Jq();
            _CashAuthcode = "";
            Plugins = new List<HongshPayClientPlugin>();
            Config = new HongshPayClientConfig();
            TradeManager = new HongshPayTradeManager(Config);
        }


        static HongshPayClientContext() {
            Default = new HongshPayClientContext();
        }


        public static readonly HongshPayClientContext Default;


        private string _CashAuthcode;


        private TradeState _CashState;

        private string _CashStateDescript;

        private int _CashTime;
    }
}
